/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.util.ByteUtil;
/*    */ import com.zimbra.common.util.FileSegmentDataSource;
/*    */ import java.io.File;
/*    */ import java.io.IOException;
/*    */ import java.io.InputStream;
/*    */ import javax.activation.DataSource;
/*    */ import javax.activation.FileDataSource;
/*    */ import javax.mail.util.ByteArrayDataSource;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ class RedoableOpData
/*    */ {
/*    */   private int mLength;
/*    */   private DataSource mDataSource;
/*    */   
/*    */   RedoableOpData(byte[] data)
/*    */   {
/* 36 */     this.mDataSource = new ByteArrayDataSource(data, "application/octet-stream");
/* 37 */     this.mLength = data.length;
/*    */   }
/*    */   
/*    */   RedoableOpData(File file) {
/* 41 */     this.mDataSource = new FileDataSource(file);
/* 42 */     this.mLength = ((int)file.length());
/*    */   }
/*    */   
/*    */   RedoableOpData(File file, long offset, int length) {
/* 46 */     this.mDataSource = new FileSegmentDataSource(file, offset, length);
/* 47 */     this.mLength = length;
/*    */   }
/*    */   
/*    */   RedoableOpData(DataSource dataSource, int length) {
/* 51 */     this.mDataSource = dataSource;
/* 52 */     this.mLength = length;
/*    */   }
/*    */   
/*    */   int getLength() {
/* 56 */     return this.mLength;
/*    */   }
/*    */   
/*    */   byte[] getData() throws IOException
/*    */   {
/* 61 */     return ByteUtil.getContent(this.mDataSource.getInputStream(), this.mLength);
/*    */   }
/*    */   
/*    */   InputStream getInputStream() throws IOException
/*    */   {
/* 66 */     return this.mDataSource.getInputStream();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/RedoableOpData.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */